<?php
class Listas_Form_Diligenciarsecciones extends Form_Cna {
	
    protected $elementosSeccion;
		
	public function __construct($options = null) {
		parent::__construct($options);
	}
	
	public function setElementosSeccion($elementosSeccion) {
		$this->elementosSeccion = $elementosSeccion;
	}
	
	public function init() {
		$this->setName('diligenciar');
		$this->setMethod("post");
		
		$elements[] = new Zend_Form_Element_Text("paginacaracteristicas");
		
//		Zend_Debug::dump($this->elementosSeccion);
		foreach ($this->elementosSeccion as $key =>$elemento){
		    $codigo = "codtramiteelemento";
		    if (isset($elemento["codtramiteseccion"])):
		        $codigo = "codtramiteseccion";
                $element = new Zend_Form_Element_Hidden("seccion_{$elemento["codseccionlista"]}");
                $element->setValue($elemento["codseccionlista"]);
                $elements[] = $element;
             else:
                $elements[] = new Zend_Form_Element_Hidden("codseccionlista");
             endif;
             
            $elements[] = new Zend_Form_Element_Hidden("campocodigo");
            		    
		    $element = new Zend_Form_Element_Text("peso_{$elemento[$codigo]}");
			$element->setLabel($elemento["nombre"]."@".$elemento["seccioncna"]);
		    $element->setRequired(true);
			$element->addFilter('StripTags');
			$element->addFilter('StringTrim');
			$element->setAttrib("size",3);
		    $element->setDescription(" (Ejemplo: 25)");
		    $element->addValidator("Float");
		    $element->addValidator(new Zend_Validate_Between(0,100));
		    $elements[] = $element;
		    			
	        $element = new Zend_Form_Element_Textarea("justificacionpeso_{$elemento[$codigo]}");
			$element->setRequired(true);
	        $element->addFilter('StripTags');
			$element->addFilter('StringTrim');
//			$element->addFilter('StringToUpper');
			$element->setAttrib("rows",3);
			$element->setAttrib("style","width:95%");
			$elements[] = $element;
		}
		
        $element = new Zend_Form_Element_Text("totalpeso");
        $element->helper = "formNote";
        $element->setAttrib("readonly", "readonly");
        $element->setAttrib("size", 3);
        $elements[] = $element;
		
		$element = new Zend_Form_Element_Submit('btnSubmit');
		$element->setLabel('Guardar');
		$element->setValue('Guardar');
		$element->setAttrib("class", "iceCmdBtn");
		$elements[] = $element;
		
		$this->addElements ($elements);
		
	    $this->loadViewScriptDecorators();
//		$this->loadTableDecorators();
	}
	
	public function loadViewScriptDecorators() {
		$this->setDecorators ( array (array ('viewScript', array ('viewScript' => 'viewscripts/ponderar_form.phtml' ) ) ) );
	}
	
}
